﻿using System;

public static class ConsoleTweaks
{
    /// <summary>
    /// Centers a string on a row of the console, cuts the beginning in case of overflow
    /// </summary>
    public static void CenterTextOnRow(string text, int row)
    {
        if (row < Console.WindowHeight)
        {
            int beginning = (Console.WindowWidth - text.Length) / 2;

            if (text.Length < Console.WindowWidth)
            {
                Console.SetCursorPosition(beginning, row);
                Console.WriteLine(text);
            }
            else
            {
                string visibleText = text.Substring(text.Length - Console.WindowWidth + 1);
                Console.SetCursorPosition(0, row);
                Console.WriteLine(visibleText);
            }
        }
    }

    /// <summary>
    /// Remove the sliders of the console
    /// </summary>
    public static void RemoveScrollBars()
    {
        Console.BufferHeight = Console.WindowHeight;
        Console.BufferWidth = Console.WindowWidth;
    }
}

